home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7648 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.6 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
  4. Subject: Re: Access carry flag from C
  5. Date: Sat, 24 Feb 96 17:37:59 GMT
  6. Organization: none
  7. Message-ID: <825183479snz@genesis.demon.co.uk>
  8. References: <Dn1C9z.DGv.0.net@indra.com> <1996Feb1922.17.19.879@koobera.math.uic.edu> <31298D20.41C6@bazis.nl> <danpop.824859220@rscernix> <312AFACE.41C6@bazis.nl> <824997378snz@genesis.demon.co.uk> <312D850C.2781@bazis.nl>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <312D850C.2781@bazis.nl> fkorntne@bazis.nl "Franz Korntner" writes:
  15.  
  16. >Lawrence Kirby wrote:
  17. >
  18. >> No. The value defined for INT_MAX in limits.h is the maximum value an int
  19. >> can hold *on that particular implementation*. The standard requires that
  20. >> INT_MAX be at least 32767 on all implementations (but it can be and
  21. >> often is higher). So on any implementation:
  22. >> 
  23. >>   int x = INT_MAX+1;
  24. >> 
  25. >> is a guaranteed overflow.
  26. >
  27. >Wrong. The limits are minima. The above operation does not have to overflow!
  28.  
  29. 5.2.4.2.1
  30.  
  31. "- maximum value for an object of type int
  32.    INT_MAX                              +32767"
  33.  
  34. INT_MAX is a maximum (as its name suggests). +32767 is a minimum and is the
  35. smallest value an implementation is allowed to define INT_MAX to be. Hence
  36. int's on any implementation are resuires to be able to represent integers
  37. up to at least 32767. See Tanmoy's post for a more detailed (and correct)
  38. explanation.
  39.  
  40. >> >and what I really miss in the
  41. >> >standard and/or implementation is a inline function 'maxlimitof(int)',
  42. >> >analogical to 'sizeof(int)'.
  43. >> 
  44. >> That is precisely what INT_MAX gives you.
  45. >
  46. >INT_MAX is a constant. On some platforms you can force GCC to assume int's
  47. >to be 16 bit values. What about INT_MAX then?!?
  48.  
  49. To remain conforming gcc would have to ensure that INT_MAX is defined to
  50. a value consistent with how an integer is represented for that particular
  51. compilation. It can do that easily by using conditional preprocessing within
  52. limits.h. Whether it does that in practice is another matter - as soon as
  53. you start playing around with type representations you will hit trouble
  54. if every translation unit doesn't use the same one, notably the standard
  55. library. Most likely you simply don't get a conforming compiler if you
  56. try to do this, notably where gcc is used with the standard library supplied
  57. by the system.
  58.  
  59. -- 
  60. -----------------------------------------
  61. Lawrence Kirby | fred@genesis.demon.co.uk
  62. Wilts, England | 70734.126@compuserve.com
  63. -----------------------------------------
  64.